package gdkm.wsz.dao;

import gdkm.wsz.pojo.Order;
import gdkm.wsz.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDAO {
    @Select("select * from tb_user where id = #{id}")
    @Results(id = "userMAP", value = {
            @Result(property = "id", column = "id"),
            @Result(property = "orders", column = "id",
                    many = @Many(select = "gdkm.wsz.dao.OrderDAO.findByUserId"))
    })
    public User findById(Integer id);
    @Select("select * from tb_user")
    public List<User> findAll();
    @Insert("insert into tb_user values(null,#{username},#{address})")
    public boolean save(User user);
    @Update("update tb_user set username = #{username},address = #{address} where id = #{id}")
    public boolean update(User user);
    @Delete("delete from tb_user where id = #{id}")
    public boolean delete(User  user);

}
